package example.org;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ToggleButton;

public class Main extends Activity implements OnClickListener {
	/** Called when the activity is first created. */
	private Button mButtonShare, mButtonSetting, mButtonAbout, mButtonExit;
	private ToggleButton mToggleStart;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		mToggleStart = (ToggleButton) findViewById(R.id.toggleStart);
		mButtonShare = (Button) findViewById(R.id.btnShare);
		mButtonSetting = (Button) findViewById(R.id.btnSetting);
		mButtonAbout = (Button) findViewById(R.id.btnAbout);
		mButtonExit = (Button) findViewById(R.id.btnExit);

		mButtonExit.setOnClickListener(this);
		mButtonShare.setOnClickListener(this);
		mButtonSetting.setOnClickListener(this);
		mButtonAbout.setOnClickListener(this);
		mToggleStart.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == mButtonExit) {
			finish();
		} else if (v == mButtonShare) {
			 Intent i = new Intent(this, ShareImage.class);
			 startActivity(i);
		} else if (v == mButtonSetting) {
			 Intent i = new Intent(this, Setting.class);
			 startActivity(i);
		} else if (v == mButtonAbout) {
			Intent i = new Intent(this, About.class);
			startActivity(i);
		} else if (v == mToggleStart) {
			Intent intent = new Intent(this, ScreenShot.class);

			if (mToggleStart.isChecked()) {
				startService(intent);
			} else {
				stopService(intent);
			}
		}
	}
}